<template>
    <div class="icons">
        <swiper>
            <swiper-slide v-for="(page,index) of pages" :key="index">
                <div class="icon" v-for="item of page" :key="item.id">
                    <div class="icon-img">
                        <img :src="item.imgUrl" alt="" class="icon-img-content">
                    </div>
                    <p class="icon-intro">{{item.content}}</p>
                </div>
            </swiper-slide>
        </swiper>
    </div>
</template>

<script>
export default {
  name: 'Icons',
  data () {
    return {
      iconList: [{
        id: '001',
        imgUrl: 'https://m.tuniucdn.com/fb2/t1/G2/M00/94/A9/Cii-T1hmH2yIURNDAAAJyfc0kUYAAGMPAP_79EAAAnh702_w120_h120_c1_t0.png',
        content: '全球wefi'
      }, {
        id: '002',
        imgUrl: 'https://m3.tuniucdn.com/fb2/t1/G5/M00/BA/32/Cii-slrQDBuIDwW6AAAHDbmII-4AAFiJQJLm-kAAAcl406_w120_h120_c1_t0.png',
        content: '全球wefi'
      }, {
        id: '003',
        imgUrl: 'https://m.tuniucdn.com/fb2/t1/G3/M00/32/38/Cii_Llli3baIed2wAAACgMRu23IAADA0wP__WgAAAKY669_w120_h120_c1_t0.png',
        content: '全球wefi'
      }, {
        id: '004',
        imgUrl: 'https://m.tuniucdn.com/fb2/t1/G1/M00/84/64/Cii-U1ir_DyIWjOQAAAMzJwlIzUAAHmAQP_8xsAAAzl573_w120_h120_c1_t0.png',
        content: '全球wefi'
      }, {
        id: '005',
        imgUrl: 'https://m.tuniucdn.com/fb2/t1/G1/M00/56/7D/Cii9EViFfe2IVXYOAAAJ0Vcji84AAHIGQP_9XMAAAqN711_w120_h120_c1_t0.png',
        content: '全球wefi'
      }, {
        id: '006',
        imgUrl: 'https://m4.tuniucdn.com/fb2/t1/G5/M00/B5/4B/Cii-tFrMg4CINw_XAAAFOVqbjXkAAFafgP_-qYAAAVa328_w120_h120_c1_t0.png',
        content: '全球wefi'
      }, {
        id: '007',
        imgUrl: 'https://m4.tuniucdn.com/fb2/t1/G5/M00/B5/4B/Cii-tFrMg4CINw_XAAAFOVqbjXkAAFafgP_-qYAAAVa328_w120_h120_c1_t0.png',
        content: '全球wefi'
      }, {
        id: '008',
        imgUrl: 'https://m4.tuniucdn.com/fb2/t1/G5/M00/B5/4B/Cii-tFrMg4CINw_XAAAFOVqbjXkAAFafgP_-qYAAAVa328_w120_h120_c1_t0.png',
        content: '全球wefi'
      }, {
        id: '009',
        imgUrl: 'https://m4.tuniucdn.com/fb2/t1/G5/M00/B5/4B/Cii-tFrMg4CINw_XAAAFOVqbjXkAAFafgP_-qYAAAVa328_w120_h120_c1_t0.png',
        content: '全球wefi'
      }, {
        id: '0010',
        imgUrl: 'https://m4.tuniucdn.com/fb2/t1/G5/M00/B5/4B/Cii-tFrMg4CINw_XAAAFOVqbjXkAAFafgP_-qYAAAVa328_w120_h120_c1_t0.png',
        content: '全球wefi'
      }]
    }
  },
  computed: {
    pages () {
      let pages = []
      this.iconList.forEach((item, index) => {
        let page = Math.floor(index / 8)
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  }
}
</script>

<style lang="stylus" scoped>
@import  '~styles/varibles.styl'
  .icons >>> .swiper-container
    height: 0
    padding-bottom: 50%
    overflow: hidden
  .icon
    width: 25%
    height: 0
    float: left
    text-align: center
    position: relative
    padding-bottom: 25%
    .icon-img
      position: absolute
      top: 0
      left: 0
      right: 0
      bottom: .44rem
    .icon-img-content
      display: block
      height: 100%
      margin: 0 auto
    .icon-intro
      position: absolute
      left: 0
      right: 0
      bottom: 0
      height: .44rem
      line-height: .44rem
      text-align: center
      color: $color3

</style>
